package com.atguigu.service.oss.controller;

import com.atguigu.guli.service.base.exception.GuliException;
import com.atguigu.guli.service.base.result.R;
import com.atguigu.service.oss.service.OssUpdateImageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/admin/oss")
public class OssUpdateImage {

    @Autowired
    OssUpdateImageService updateImageService;

    @ApiOperation("讲师头像上传")
    @PostMapping("/edu/avatar")
    public R updateAvater(@RequestParam("file") MultipartFile multipartFile,
                          @RequestParam("module")String avater){
        String path = updateImageService.updateImage(multipartFile, avater);
        return R.ok().data("data",path);
    }

    @ApiOperation(("删除文件"))
    @DeleteMapping("/delete/image")
    public R deleteImage(@RequestParam("path")String path,@RequestParam("module") String module){

        updateImageService.deleteFile(path,module);
        return R.ok();
    }
}
